<template>

  <div class="app-container">
    <a-card style="margin-bottom: 16px">
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="学校ID" prop="schoolId">
          <el-select clearable v-model="queryParams.groupId" placeholder="请选择">
            <el-option
                v-for="item in groupList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="search">搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          <el-button icon="Refresh" @click="outputAllScoreExcel">导出汇总表</el-button>
        </el-form-item>
      </el-form>
    </a-card>


    <a-card>
      <el-table row-key="id"
                :expand-row-keys="expandedRowKeys" :data="shoolScoreList">
        <el-table-column type="expand">
          <template #default="props">
            <el-table row-key="subId" :tree-props="{ children: 'childScoreItemList'}" ref="regionTable"
                      :data="props.row.scoreItemList" :border="childBorder">

              <el-table-column width="200" label="成绩项">
                <template #default="scope">
                  {{ scope.row.name }}
                </template>
              </el-table-column>

              <el-table-column width="180" label="成绩" align="center" prop="score"/>
              <el-table-column label=" " align="center" prop=""/>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column width="180" label="名称" align="center" prop="unitName"/>
        <el-table-column width="180" label="名次" align="center" prop="mc"/>
        <el-table-column width="180" label="成绩" align="center" prop="score"/>
        <el-table-column label="" align="center" prop=""/>
      </el-table>
      <pagination
          v-show="total>0"
          :total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
      />
    </a-card>

  </div>


</template>

<script>
import {deptTreeSelect} from "@/api/business/subject";
import {list, update, lottery} from "@/api/business/orchestrate";
import {getSchoolScoreList, getStudentScoreList} from "@/api/business/score";
import {ref, watch} from 'vue';
import {listSchool} from "@/api/business/school.js";
import {message} from "ant-design-vue";
import {listGroup} from "@/api/business/group.js";

export default {
  name: "LotteryPage",
  data() {
    const {proxy} = getCurrentInstance();
    const subName = ref("");
    let queryParams = {
      subId: null,
      pageNum: 1,
      pageSize: 10,
      schoolId: null,
      no: null,
      avatarSrc: null,
      name: null,
      stuNo: null,
      className: null,
      nation: null,
      sex: null,
      birth: null,
      birthPlace: null,
      cardId: null,
      mailAddress: null,
      mobile: null,
      oneConfirm: null,
      oneConfirmTime: null,
      twoConfirm: null,
      twoConfirmTime: null,
      editShow: true,
      schoolList: [],
      studentScoreList: [],
    };
    return {
      total: 0,
      queryParams,
      shoolScoreList: [],
      showSearch: true,
      expandedRowKeys: [],
      proxy,
      groupList: []
    }

  },
  mounted() {
    this.getGroupList();
    this.getSchoolScoreList();
    // this.getStudentScoreList();
  },
  // watch(){
  //
  // },
  beforeUnmount() {

  },

  methods: {
    search() {
      this.getSchoolScoreList();
      // this.getStudentScoreList();
    },
    getGroupList() {
      let that = this;
      listGroup(
          {pageSize: 0}
      ).then(response => {
        that.groupList = response.rows;
      });
    },
    getSchoolScoreList() {
      let that = this;
      getSchoolScoreList(-1, this.queryParams.groupId).then(res => {
        that.shoolScoreList = res.data;
      })
    },
    getStudentScoreList() {
      let that = this;
      getStudentScoreList(-1).then(res => {
        that.studentScoreList = res.data;
      })
    },
    outputAllScoreExcel() {
      let that = this;
      this.proxy.download('business/score/outputAllScoreExcel?groupId=' + this.queryParams.groupId, {}, `成绩汇总表-${new Date().getTime()}.xlsx`)
    }
  }
}
</script>

<style>
</style>
